package cc.javaee.bbs.dao.activity;

import cc.javaee.bbs.dao.BaseDao;
import cc.javaee.bbs.model.activity.KbrActivityDynamic;
import cc.javaee.bbs.params.DbResultMap;
import cc.javaee.bbs.params.WebParams;
import cc.javaee.bbs.tool.DataFormatUtil;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class ActivityDynamicDao extends BaseDao {
	String ns="kbr_activity_dynamic.";
	public void insert(KbrActivityDynamic KbrActivityDynamic) {
		this.getSqlSession().insert(ns+"insert", KbrActivityDynamic);
	}
	
	public List<DbResultMap> findDbList(WebParams param) {
		List<DbResultMap> list=this.getSqlSession().selectList(ns+"findDb", param);
		if(list!=null&&list.size()>0){
			for (DbResultMap act : list) {
				act.put("enStartTimeStr",DataFormatUtil.toDateStrNull(act.getDate("enStartTime")));
				act.put("enEndTimeStr",DataFormatUtil.toDateStrNull(act.getDate("enEndTime")));
				act.put("startTimeStr",DataFormatUtil.toDateStrNull(act.getDate("startTime")));
				act.put("endTimeStr",DataFormatUtil.toDateStrNull(act.getDate("endTime")));
			}
		}
		return list;
	}
	
	public DbResultMap findDb(WebParams param) {
		List<DbResultMap> list=this.getSqlSession().selectList(ns+"findDb", param);
		DbResultMap db=null;
		if(list!=null&&list.size()>0){
			for (DbResultMap act : list) {
				db=act;
			}
		}
		return db;
	}
	
}